/* ===================

AX2E (AXESCON XACML 2.0 Engine) is the Java authorization engine, which implements OASIS XACML 2.0 standard.
Copyright (C) 2007 AXESCON LLC

This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.

This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA


Contact: AXESCON LLC - info{at}axescon.com

 =================== */
package axescon.xacml.model.explain;

import java.util.LinkedList;

/**
 * @author argyn
 *         Date: Oct 17, 2005
 *         Time: 11:17:38 PM
 *         Responsibilities:
 *         each decision step is supposed to explain why a particular step drawn a particular decision
 *         and leads to another step
 */
public class DecisionStep {
    String sentence;

    public DecisionStep(String sentence, DecisionStep parent) {
        this.sentence = sentence;
        this.parent = parent;
    }

    public DecisionStep(String sentence) {
        this(sentence, null);
    }

    public String getSentence() {
        return sentence;
    }

    public void setSentence(String sentence) {
        this.sentence = sentence;
    }

    DecisionStep parent;
    /**
     * List<DecisionStep>
     */
    LinkedList children;

    public DecisionStep getParent() {
        return parent;
    }

    public void setParent(DecisionStep parent) {
        this.parent = parent;
    }

    public LinkedList getChildren() {
        return children;
    }

    public void setChildren(LinkedList children) {
        this.children = children;
    }

    public DecisionStep addChild(String sentence) {
        if (getChildren() == null) setChildren(new LinkedList());
        DecisionStep ret = new DecisionStep(sentence, this);
        getChildren().add(ret);
        return ret;
    }

    public DecisionStep addSibling(String sentence) {
        DecisionStep ret = new DecisionStep(sentence, this.getParent());
        return ret;
    }

    public void append(String sentence) {
        this.sentence += sentence;
    }
}
